<?php
	include("mysql_connect.php");
	
	$strKeyWord = $_POST['arg'];
	
	$strSqlCommand = "SELECT FirstName, LastName FROM REAgent";
	
	if(strlen($strKeyWord) > 0 && strcmp($strKeyWord, "Zip Code or Location") != 0)
	{
		$strSqlCommand .= " WHERE FirstName LIKE '%".$strKeyWord."%' OR LastName LIKE '%".$strKeyWord."%'";
	}
	$strSqlCommand .= " ORDER BY LastName";
	
	$result = mysql_query($strSqlCommand);

	//$ArrayAgent = array("Kevin Adams","Amelia Ahne","Sabastion Battaglia","Harold Cannily");
	
//	echo '<li data-role="list-divider" role="heading">A</li>';
	//foreach($ArrayAgent as $strName)
	$Divider = "0";
	while($rowMedia = @mysql_fetch_row($result))	
	{
		if(strncmp( $rowMedia[1], $Divider, 1) != 0)
		{
			$Divider = substr($rowMedia[1],0,1);
			echo '<li data-role="list-divider" role="heading">'.$Divider.'</li>';		
		}
		echo '<li data-theme="c"> <a href="#page6" data-transition="slide">'.$rowMedia[0]. ' '.$rowMedia[1].'</a></li>';
		//echo '<li data-theme="c"> <a href="#page6" data-transition="slide">'.$strName.'</a></li>';
	}
?>